package com.zhku.laosiji.service.Impl;

import com.zhku.laosiji.dao.NoticeMapper;
import com.zhku.laosiji.pojo.Notice;
import com.zhku.laosiji.service.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by LINWENHAO on 2018/9/11.
 */
@Service
public class NoticeServiceImpl implements NoticeService {
    @Autowired
    NoticeMapper noticeMapper;

    @Override
    public List<Notice> findALl(String keyword) {
        return noticeMapper.selectAll(keyword);
    }

    @Override
    public void delete(Integer nid) {
        noticeMapper.deleteByPrimaryKey(nid);
    }

    @Override
    public Notice findById(Integer id) {
        return noticeMapper.selectByPrimaryKey(id);
    }

    @Override
    public int saveNotice(Notice notice) {
        return noticeMapper.insert(notice);
    }

    @Override
    public int updateNotice(Notice notice) {
        return noticeMapper.updateByPrimaryKey(notice);
    }

    @Override
    public List<Notice> selectAllByTop10() {
        return noticeMapper.selectAllByTop10();
    }
}
